<cfif Session.id EQ 0><cflocation url="../index.cfm" ></cfif>
<cfobject name="comExport" component="export">

<cfparam name="action" default="">
<cfswitch expression="#action#">

	<cfcase value="getPDF">
		<cfif IsDefined('url.year') AND IsDefined('url.year2')>
			<cfinvoke
				component="#comExport#"
				method="getWeekList"
				year='#url.year2#'
				year2='#url.year#'
				returnVariable="query">

			<cfdocument format="flashpaper" unit="cm" pageType="A4" localUrl="yes">
			<cfif query.recordcount >
			<cfoutput query="query">
				<cfdocumentsection marginTop="4">
				<cfdocumentitem type="header"><h2>Ausbildungsnachweis</h2>
				<table cellspacing="2" cellpadding="2px" bgcolor="##EAEAEA" width="100%">
				<tr>
				<td bgcolor="white">Name des/der Auszubildenden:</td>
				<td colspan="3" bgcolor="white">#Request.user_name#</td>
				</tr>
				<tr>
				<td bgcolor="white">Ausbildungsjahr:</td>
				<td bgcolor="white">#DateFormat(query.min, 'yyyy')#</td>
				<td bgcolor="white">Ausbildungsbereich:</td>
				<td bgcolor="white">#Request.bereich#</td>
				</tr>
				<tr>
				<td bgcolor="white">Ausbildungswoche vom:</td>
				<td bgcolor="white">#DateFormat(query.min, 'dd. ')##monthAsString(Month(query.min))# #DateFormat(query.min, 'yyyy')#</td>
				<td bgcolor="white">bis:</td>
				<td bgcolor="white">#DateFormat(query.max, 'dd. ')##monthAsString(Month(query.max))# #DateFormat(query.max, 'yyyy')#</td>
				</tr>
				</table>&nbsp;</cfdocumentitem> 
				
				<cfdocumentitem type="footer"> 
				<cfoutput>Seite #cfdocument.currentsectionpagenumber# von #cfdocument.totalsectionpagecount#</cfoutput> 
				</cfdocumentitem>

				<table cellspacing="2" bgcolor="black" width="100%">
				<tr>
					<td bgcolor="##D0D0D0">&nbsp;</td>
					<td style="font-size: 10px;" bgcolor="##D0D0D0">Betriebliche T&auml;tigkeiten, Unterweisungen,  betrieblicher Unterricht, sonstige Schulungen, Themen des Berufsschulunterrichts</td>
				</tr>
				<cfinvoke
					component="#comExport#"
					method="getEntriesList"
					week_id='#query.id#'
					returnVariable="query2">
				#query2#
				</table>
				<div class="signature"><table style="margin-top: 50px;" cellspacing="20" width="100%">
				<tr>
				<td style="border-top: 1px solid black; padding-bottom: 50px;">Datum, Unterschrift Auszubildende/r</td>
				<td style="border-top: 1px solid black; padding-bottom: 50px;">Datum, Unterschrift Ausbildende/r oder Ausbilder/in</td>
				</tr>
				<tr>
				<td style="border-top: 1px solid black;">Datum, Unterschrift gesetzlicher Vertreter</td>
				<td style="border-top: 1px solid black;">Datum, weitere Sichtvermerke (z. B. Lehrer/in)</td>
				</tr>
				</table></div>
				</cfdocumentsection>
			</cfoutput>
			<cfelse>
				<h2>Keine Daten im gew�hlten Zeitraum verf�gbar.</h2>
			</cfif>
			</cfdocument>


		</cfif>
	</cfcase>

	<cfdefaultcase>
		<cfscript>
			yearList = comExport.getYearList();
		</cfscript>
		<cf_template i="1">
			<fieldset>
			<legend>Bitte Zeitraum ausw&auml;hlen:</legend>
			<form method="post" action="javascript:window.location='export.cfm?action=getPDF&year='+$('year2').value+$('week2').value+'&year2='+$('year').value+$('week').value;">
			<p>von:<br>
			<select name="year" id="year">
				<cfoutput query="yearList">
					<option value="#Left(year, 4)#">#Left(year, 4)#</option>
				</cfoutput>
			</select>
			<select name="week" id="week">
			<cfset CountVar = 1>
			<cfloop condition = "CountVar LESS THAN OR EQUAL TO 53">
	<cfoutput><option value="#NumberFormat(CountVar, '00')#" <cfif Week(Now()) EQ CountVar>selected</cfif>>Kalenderwoche #CountVar#</option></cfoutput>
	<cfset CountVar = CountVar + 1>
</cfloop>
			</select>
			</p>
			<p>bis:<br>
			<select name="year2" id="year2">
				<cfoutput query="yearList">
					<option value="#Left(year, 4)#">#Left(year, 4)#</option>
				</cfoutput>
			</select>
			<select name="week2" id="week2">
			<cfset CountVar = 1>
			<cfloop condition = "CountVar LESS THAN OR EQUAL TO 53">
	<cfoutput><option value="#NumberFormat(CountVar, '00')#" <cfif Week(Now()) EQ CountVar>selected</cfif>>Kalenderwoche #CountVar#</option>
	<cfset CountVar = CountVar + 1>
</cfoutput>
</cfloop>
			</select></p>
			<p>&nbsp;</p>
			<input type="submit" value="PDF erstellen" class="submit">
			</form>
			</fieldset>
		</cf_template>
	</cfdefaultcase>
</cfswitch>